<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<title>Type - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/language/type","wgTitle":"cpp/language/type","wgCurRevisionId":141533,"wgArticleId":13105,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo with reason"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/language/type","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1,"gadget-MathJax":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_language_type skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">Type</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../language.html" title="cpp/language">language</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../compiler_support.html" title="cpp/compiler support"> Compiler support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> Freestanding and hosted</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header"> Standard library headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req"> Named requirements </a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../feature_test.html" title="cpp/feature test"> Feature test macros </a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#Language_support" title="cpp/utility"> Language support library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts"> Concepts library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../meta.html" title="cpp/meta"> Metaprogramming library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error"> Diagnostics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility"> General utilities library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../container.html" title="cpp/container"> Containers library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator"> Iterators library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> Ranges library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm"> Algorithms library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric"> Numerics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale"> Localizations library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io"> Input/output library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem"> Filesystem library</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex"> Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread"> Concurrency support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental"> Technical specifications</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../symbol_index.html" title="cpp/symbol index"> Symbols index</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../links/libs.html" title="cpp/links/libs"> External libraries</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../language.html" title="cpp/language"> C++ language</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> General topics</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../preprocessor.html" title="cpp/preprocessor"> Preprocessor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../comments.html" title="cpp/comment"> Comments</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../keywords.html" title="cpp/keyword"> Keywords</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="escape.html" title="cpp/language/escape"> Escape sequences</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="statements.html" title="cpp/language/statements"> Flow control</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Conditional execution statements</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="if.html" title="cpp/language/if"><tt>if</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="switch.html" title="cpp/language/switch"><tt>switch</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Iteration statements (loops)</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="for.html" title="cpp/language/for"><tt>for</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="range-for.html" title="cpp/language/range-for"> range-<code>for</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="while.html" title="cpp/language/while"><tt>while</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="do.html" title="cpp/language/do"> <code>do-while</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Jump statements </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="continue.html" title="cpp/language/continue"><tt>continue</tt></a> - <a href="break.html" title="cpp/language/break"><tt>break</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="goto.html" title="cpp/language/goto"><tt>goto</tt></a> - <a href="return.html" title="cpp/language/return"><tt>return</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="functions.html" title="cpp/language/functions"> Functions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function.html" title="cpp/language/function"> Function declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="lambda.html" title="cpp/language/lambda"> Lambda function expression</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="inline.html" title="cpp/language/inline"> <code>inline</code> specifier</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="except_spec.html" title="cpp/language/except spec"> Dynamic exception specifications</a> <span class="t-mark-rev t-until-cxx20">(until C++20)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="noexcept_spec.html" title="cpp/language/noexcept spec"> <code>noexcept</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Exceptions</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="throw.html" title="cpp/language/throw"> <code>throw</code>-expression</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="try_catch.html" title="cpp/language/try catch"> <code>try</code>-<code>catch</code> block</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Namespaces</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="namespace.html" title="cpp/language/namespace"> Namespace declaration</a>  </td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="namespace_alias.html" title="cpp/language/namespace alias"> Namespace aliases</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Types</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="types.html" title="cpp/language/types"> Fundamental types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="enum_class.html" title="cpp/language/enum"> Enumeration types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function.html" title="cpp/language/function"> Function types</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class.html" title="cpp/language/class"> Class/struct types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="union.html" title="cpp/language/union"> Union types</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Specifiers</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="decltype.html" title="cpp/language/decltype"><tt>decltype</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="auto.html" title="cpp/language/auto"><tt>auto</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="alignas.html" title="cpp/language/alignas"><tt>alignas</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="cv.html" title="cpp/language/cv"> <code>const</code>/<code>volatile</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constexpr.html" title="cpp/language/constexpr"><tt>constexpr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="storage_duration.html" title="cpp/language/storage duration"> Storage duration specifiers</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="initialization.html" title="cpp/language/initialization"> Initialization</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="default_initialization.html" title="cpp/language/default initialization"> Default initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="value_initialization.html" title="cpp/language/value initialization"> Value initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="zero_initialization.html" title="cpp/language/zero initialization"> Zero initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="copy_initialization.html" title="cpp/language/copy initialization"> Copy initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="direct_initialization.html" title="cpp/language/direct initialization"> Direct initialization</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="aggregate_initialization.html" title="cpp/language/aggregate initialization"> Aggregate initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="list_initialization.html" title="cpp/language/list initialization"> List initialization</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constant_initialization.html" title="cpp/language/constant initialization"> Constant initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="reference_initialization.html" title="cpp/language/reference initialization"> Reference initialization</a></td></tr>
</table></div></td></tr>
</table></div>
</div>
<div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> <a href="expressions.html" title="cpp/language/expressions"> Expressions</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="value_category.html" title="cpp/language/value category"> Value categories</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="eval_order.html" title="cpp/language/eval order"> Order of evaluation</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="operators.html" title="cpp/language/operators"> Operators</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_precedence.html" title="cpp/language/operator precedence"> Operator precedence</a></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_alternative.html" title="cpp/language/operator alternative"> Alternative representations</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="expressions.html#Literals" title="cpp/language/expressions"> Literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="bool_literal.html" title="cpp/language/bool literal"> Boolean</a> - <a href="integer_literal.html" title="cpp/language/integer literal"> Integer</a> - <a href="floating_literal.html" title="cpp/language/floating literal"> Floating-point</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="character_literal.html" title="cpp/language/character literal"> Character</a> - <a href="string_literal.html" title="cpp/language/string literal"> String</a> - <a href="nullptr.html" title="cpp/language/nullptr"><tt>nullptr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr> 
<tr class="t-nv"><td colspan="5"> <a href="user_literal.html" title="cpp/language/user literal"> User-defined</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Utilities</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="attributes.html" title="cpp/language/attributes"> Attributes</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Types</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="typedef.html" title="cpp/language/typedef"> <code>typedef</code> declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="type_alias.html" title="cpp/language/type alias"> Type alias declaration</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Casts</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="implicit_cast.html" title="cpp/language/implicit conversion"> Implicit conversions</a> - <a href="explicit_cast.html" title="cpp/language/explicit cast"> Explicit conversions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="static_cast.html" title="cpp/language/static cast"><tt>static_cast</tt></a> - <a href="dynamic_cast.html" title="cpp/language/dynamic cast"><tt>dynamic_cast</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="const_cast.html" title="cpp/language/const cast"><tt>const_cast</tt></a> - <a href="reinterpret_cast.html" title="cpp/language/reinterpret cast"><tt>reinterpret_cast</tt></a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Memory allocation</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="new.html" title="cpp/language/new"> <code>new</code> expression</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="delete.html" title="cpp/language/delete"> <code>delete</code> expression</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="classes.html" title="cpp/language/classes"> Classes</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class.html" title="cpp/language/class"> Class declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="initializer_list.html" title="cpp/language/constructor"> Constructors</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="this.html" title="cpp/language/this"> <code>this</code> pointer</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="access.html" title="cpp/language/access"> Access specifiers</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="friend.html" title="cpp/language/friend"> <code>friend</code> specifier</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Class-specific function properties</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="virtual.html" title="cpp/language/virtual"> Virtual function</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="override.html" title="cpp/language/override"> <code>override</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="final.html" title="cpp/language/final"> <code>final</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="explicit.html" title="cpp/language/explicit"><tt>explicit</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="static.html" title="cpp/language/static"><tt>static</tt></a> </td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Special member functions</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="default_constructor.html" title="cpp/language/default constructor"> Default constructor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="copy_constructor.html" title="cpp/language/copy constructor"> Copy constructor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="move_constructor.html" title="cpp/language/move constructor"> Move constructor</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="as_operator.html" title="cpp/language/as operator" class="mw-redirect"> Copy assignment</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="move_operator.html" title="cpp/language/move operator" class="mw-redirect"> Move assignment</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="destructor.html" title="cpp/language/destructor"> Destructor</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="templates.html" title="cpp/language/templates"> Templates</a> </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class_template.html" title="cpp/language/class template"> Class template </a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function_template.html" title="cpp/language/function template"> Function template </a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="template_specialization.html" title="cpp/language/template specialization"> Template specialization</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="parameter_pack.html" title="cpp/language/parameter pack"> Parameter packs</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Miscellaneous </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="asm.html" title="cpp/language/asm"> Inline assembly</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="history.html" title="cpp/language/history"> History of C++</a></td></tr>
</table></div></td></tr>
</table></div>
</div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="basic_concepts.html" title="cpp/language/basic concepts"> Basic Concepts</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../keywords.html" title="cpp/keyword"> Language keywords</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="charset.html" title="cpp/language/charset"> Character sets and encodings</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="translation_phases.html" title="cpp/language/translation phases"> Phases of translation</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../comments.html" title="cpp/comment"> Comments</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="main_function.html" title="cpp/language/main function"> The main() function</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="punctuators.html" title="cpp/language/punctuators"> Punctuation</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="name.html" title="cpp/language/identifiers"> Names and identifiers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <strong class="selflink"> Types</strong> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="types.html" title="cpp/language/types"> Fundamental types</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="objects.html" title="cpp/language/object"> Objects</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="scope.html" title="cpp/language/scope"> Scope</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="lifetime.html" title="cpp/language/lifetime"> Object lifetime</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="storage_duration.html" title="cpp/language/storage duration"> Storage duration and linkage</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="definition.html" title="cpp/language/definition"> Definitions and ODR</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="lookup.html" title="cpp/language/lookup"> Name lookup</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="qualified_lookup.html" title="cpp/language/qualified lookup"> Qualified name lookup</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="unqualified_lookup.html" title="cpp/language/unqualified lookup"> Unqualified name lookup</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="as_if.html" title="cpp/language/as if"> The as-if rule</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="ub.html" title="cpp/language/ub"> Undefined behavior</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="memory_model.html" title="cpp/language/memory model"> Memory model</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="modules.html" title="cpp/language/modules"> Modules</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
</table></div>
</div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<p><a href="objects.html" title="cpp/language/object">Objects</a>, <a href="reference.html" title="cpp/language/reference">references</a>, <a href="functions.html" title="cpp/language/functions">functions</a> including <a href="template_specialization.html" title="cpp/language/template specialization">function template specializations</a>, and <a href="expressions.html" title="cpp/language/expressions">expressions</a> have a property called <i>type</i>, which both restricts the operations that are permitted for those entities and provides semantic meaning to the otherwise generic sequences of bits.
</p>
<h3><span class="mw-headline" id="Type_classification">Type classification</span></h3>
<p>The C++ type system consists of the following types:
</p>
<ul><li> <a href="types.html" title="cpp/language/types">fundamental types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_fundamental.html"><span class="kw490">std::<span class="me2">is_fundamental</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> the type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_void.html"><span class="kw456">std::<span class="me2">is_void</span></span></a></span></span>);
</li></ul>
</dd></dl>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<dl><dd><ul><li> the type <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/nullptr_t.html"><span class="kw108">std::<span class="me2">nullptr_t</span></span></a></span></span> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_null_pointer.html"><span class="kw458">std::<span class="me2">is_null_pointer</span></span></a></span></span>);
</li></ul>
</dd></dl>
</td>
<td><span class="t-mark-rev t-since-cxx11">(since C++11)</span></td></tr>
</table>
<dl><dd><ul><li> arithmetic types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_arithmetic.html"><span class="kw488">std::<span class="me2">is_arithmetic</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> floating-point types (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">float</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">double</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">long</span> <span class="kw4">double</span></span></span> and their <a href="cv.html" title="cpp/language/cv">cv-qualified versions</a>) (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_floating_point.html"><span class="kw464">std::<span class="me2">is_floating_point</span></span></a></span></span>);
</li><li> integral types (including <a href="cv.html" title="cpp/language/cv">cv-qualified versions</a>, see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_integral.html"><span class="kw462">std::<span class="me2">is_integral</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> the type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span>;
</li><li> character types:
</li></ul>
<dl><dd><ul><li> narrow character types:
</li></ul>
<dl><dd><ul><li> ordinary character types (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">char</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">signed</span> <span class="kw4">char</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">unsigned</span> <span class="kw4">char</span></span></span>)
</li></ul>
</dd></dl>
</dd></dl>
</dd></dl>
</dd></dl>
</dd></dl>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<dl><dd><dl><dd><dl><dd><dl><dd><dl><dd><ul><li> the type <span class="t-c"><span class="mw-geshi cpp source-cpp">char8_t</span></span>
</li></ul>
</dd></dl>
</dd></dl>
</dd></dl>
</dd></dl>
</dd></dl>
</td>
<td><span class="t-mark-rev t-since-cxx20">(since C++20)</span></td></tr>
</table>
<dl><dd><dl><dd><dl><dd><dl><dd><ul><li> wide character types (<span class="t-rev-inl t-since-cxx11"><span><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">char16_t</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">char32_t</span></span></span>, </span> <span><span class="t-mark-rev t-since-cxx11">(since C++11)</span></span></span><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">wchar_t</span></span></span>);
</li></ul>
</dd></dl>
<ul><li> signed integer types (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">short</span> <span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">long</span> <span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">long</span> <span class="kw4">long</span> <span class="kw4">int</span></span></span>);
</li><li> unsigned integer types (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">unsigned</span> <span class="kw4">short</span> <span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">unsigned</span> <span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">unsigned</span> <span class="kw4">long</span> <span class="kw4">int</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">unsigned</span> <span class="kw4">long</span> <span class="kw4">long</span> <span class="kw4">int</span></span></span>);
</li></ul>
</dd></dl>
</dd></dl>
</dd></dl>
<ul><li> compound types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_compound.html"><span class="kw496">std::<span class="me2">is_compound</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> <a href="reference.html" title="cpp/language/reference">reference types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_reference.html"><span class="kw486">std::<span class="me2">is_reference</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> <a href="reference.html#Lvalue_references" title="cpp/language/reference">lvalue reference types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_lvalue_reference.html"><span class="kw470">std::<span class="me2">is_lvalue_reference</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> lvalue reference to object types;
</li><li> lvalue reference to function types;
</li></ul>
</dd></dl>
<ul><li> <a href="reference.html#Rvalue_references" title="cpp/language/reference">rvalue reference types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_rvalue_reference.html"><span class="kw472">std::<span class="me2">is_rvalue_reference</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> rvalue reference to object types;
</li><li> rvalue reference to function types;
</li></ul>
</dd></dl>
</dd></dl>
<ul><li> <a href="pointer.html#Pointers" title="cpp/language/pointer">pointer types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_pointer.html"><span class="kw468">std::<span class="me2">is_pointer</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> <a href="pointer.html#Pointers_to_objects" title="cpp/language/pointer">pointer-to-object types</a>;
</li><li> <a href="pointer.html#Pointers_to_functions" title="cpp/language/pointer">pointer-to-function types</a>;
</li></ul>
</dd></dl>
<ul><li> <a href="pointer.html#Pointers_to_members" title="cpp/language/pointer">pointer-to-member types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_member_pointer.html"><span class="kw498">std::<span class="me2">is_member_pointer</span></span></a></span></span>):
</li></ul>
<dl><dd><ul><li> <a href="pointer.html#Pointers_to_data_members" title="cpp/language/pointer">pointer-to-data-member</a> types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_member_object_pointer.html"><span class="kw474">std::<span class="me2">is_member_object_pointer</span></span></a></span></span>);
</li><li> <a href="pointer.html#Pointers_to_member_functions" title="cpp/language/pointer">pointer-to-member-function</a> types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_member_function_pointer.html"><span class="kw476">std::<span class="me2">is_member_function_pointer</span></span></a></span></span>);
</li></ul>
</dd></dl>
<ul><li> <a href="array.html" title="cpp/language/array">array types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_array.html"><span class="kw466">std::<span class="me2">is_array</span></span></a></span></span>);
</li><li> <a href="function.html" title="cpp/language/function">function types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_function.html"><span class="kw484">std::<span class="me2">is_function</span></span></a></span></span>);
</li><li> <a href="enum_class.html" title="cpp/language/enum">enumeration types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_enum.html"><span class="kw478">std::<span class="me2">is_enum</span></span></a></span></span>);
</li></ul>
<dl><dd><ul><li> <a href="enum_class.html#Unscoped_enumerations" title="cpp/language/enum">unscoped enumeration types</a>;
</li><li> <a href="enum_class.html#Scoped_enumerations" title="cpp/language/enum">scoped enumeration types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">is_scoped_enum</span></span></span>);
</li></ul>
</dd></dl>
<ul><li> <a href="class.html" title="cpp/language/class">class types</a>:
</li></ul>
<dl><dd><ul><li> non-union types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_class.html"><span class="kw482">std::<span class="me2">is_class</span></span></a></span></span>);
</li><li> <a href="union.html" title="cpp/language/union">union types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_union.html"><span class="kw480">std::<span class="me2">is_union</span></span></a></span></span>).
</li></ul>
</dd></dl>
</dd></dl>
<p>For every type other than reference and function, the type system supports three additional <a href="cv.html" title="cpp/language/cv">cv-qualified versions</a> of that type (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">const</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">volatile</span></span></span>, and <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">const</span> <span class="kw4">volatile</span></span></span>).
</p><p>Types are grouped in various categories based on their properties: 
</p>
<ul><li> object types are (possibly cv-qualified) types that are not function types, reference types, or possibly cv-qualified <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_object.html"><span class="kw492">std::<span class="me2">is_object</span></span></a></span></span>);
</li><li> <a href="../named_req/ScalarType.html" title="cpp/named req/ScalarType">scalar types</a> are (possibly cv-qualified) object types that are not array types or class types (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_scalar.html"><span class="kw494">std::<span class="me2">is_scalar</span></span></a></span></span>);
</li><li> <a href="../named_req/TrivialType.html" title="cpp/named req/TrivialType">trivial types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_trivial.html"><span class="kw504">std::<span class="me2">is_trivial</span></span></a></span></span>), <a href="../named_req/PODType.html" title="cpp/named req/PODType">POD types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_pod.html"><span class="kw510">std::<span class="me2">is_pod</span></span></a></span></span>), <a href="../named_req/LiteralType.html" title="cpp/named req/LiteralType">literal types</a> (see also <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/is_literal_type.html"><span class="kw512">std::<span class="me2">is_literal_type</span></span></a></span></span>), and other categories listed in the <a href="../types.html" title="cpp/types">type traits library</a> or as <a href="../named_req.html" title="cpp/named req">named type requirements</a>.
</li></ul>
<h3><span class="mw-headline" id="Type_naming">Type naming</span></h3>
<p>A <a href="name.html" title="cpp/language/name" class="mw-redirect">name</a> can be declared to refer to a type by means of:
</p>
<ul><li> <a href="class.html" title="cpp/language/class">class</a> declaration;
</li><li> <a href="union.html" title="cpp/language/union">union</a> declaration;
</li><li> <a href="enum_class.html" title="cpp/language/enum">enum</a> declaration;
</li><li> <a href="typedef.html" title="cpp/language/typedef">typedef</a> declaration;
</li><li> <a href="type_alias.html" title="cpp/language/type alias">type alias</a> declaration.
</li></ul>
<p>Types that do not have names often need to be referred to in C++ programs; the syntax for that is known as <span class="t-spar">type-id</span>. The syntax of the type-id that names type <code>T</code> is exactly the syntax of a <a href="declarations.html" title="cpp/language/declarations">declaration</a> of a variable or function of type <code>T</code>, with the identifier omitted, except that <span class="t-spar">decl-specifier-seq</span> of the declaration grammar is constrained to <span class="t-spar">type-specifier-seq</span>, and that new types may be defined only if the type-id appears on the right-hand side of a non-template type alias declaration.
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw4">int</span><span class="sy2">*</span> p<span class="sy4">;</span>               <span class="co1">// declaration of a pointer to int</span>
<span class="kw1">static_cast</span><span class="sy1">&lt;</span><span class="kw4">int</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">(</span>p<span class="br0">)</span><span class="sy4">;</span> <span class="co1">// type-id is "int*"</span>
 
<span class="kw4">int</span> a<span class="br0">[</span><span class="nu0">3</span><span class="br0">]</span><span class="sy4">;</span>   <span class="co1">// declaration of an array of 3 int</span>
new <span class="kw4">int</span><span class="br0">[</span><span class="nu0">3</span><span class="br0">]</span><span class="sy4">;</span> <span class="co1">// type-id is "int[3]" (called new-type-id)</span>
 
<span class="kw4">int</span> <span class="br0">(</span><span class="sy2">*</span><span class="br0">(</span><span class="sy2">*</span>x<span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span><span class="br0">)</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">[</span><span class="nu0">3</span><span class="br0">]</span><span class="sy4">;</span>      <span class="co1">// declaration of an array of 2 pointers to functions</span>
                          <span class="co1">// returning pointer to array of 3 int</span>
new <span class="br0">(</span><span class="kw4">int</span> <span class="br0">(</span><span class="sy2">*</span><span class="br0">(</span><span class="sy2">*</span><span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span><span class="br0">)</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">[</span><span class="nu0">3</span><span class="br0">]</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// type-id is "int (*(*[2])())[3]"</span>
 
<span class="kw4">void</span> f<span class="br0">(</span><span class="kw4">int</span><span class="br0">)</span><span class="sy4">;</span>                    <span class="co1">// declaration of a function taking int and returning void</span>
<a href="../utility/functional/function.html"><span class="kw1064">std::<span class="me2">function</span></span></a><span class="sy1">&lt;</span><span class="kw4">void</span><span class="br0">(</span><span class="kw4">int</span><span class="br0">)</span><span class="sy1">&gt;</span> x <span class="sy1">=</span> f<span class="sy4">;</span> <span class="co1">// type template parameter is a type-id "void(int)"</span>
<a href="../utility/functional/function.html"><span class="kw1064">std::<span class="me2">function</span></span></a><span class="sy1">&lt;</span><span class="kw4">auto</span><span class="br0">(</span><span class="kw4">int</span><span class="br0">)</span> <span class="sy2">-</span><span class="sy1">&gt;</span> <span class="kw4">void</span><span class="sy1">&gt;</span> y <span class="sy1">=</span> f<span class="sy4">;</span> <span class="co1">// same</span>
 
<a href="../container/vector.html"><span class="kw1272">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span><span class="sy1">&gt;</span> v<span class="sy4">;</span>       <span class="co1">// declaration of a vector of int</span>
sizeof<span class="br0">(</span><a href="../container/vector.html"><span class="kw1272">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span><span class="sy1">&gt;</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// type-id is "std::vector&lt;int&gt;"</span>
 
<span class="kw1">struct</span> <span class="br0">{</span> <span class="kw4">int</span> x<span class="sy4">;</span> <span class="br0">}</span> b<span class="sy4">;</span>         <span class="co1">// creates a new type and declares an object b of that type</span>
sizeof<span class="br0">(</span><span class="kw1">struct</span> <span class="br0">{</span> <span class="kw4">int</span> x<span class="sy4">;</span> <span class="br0">}</span><span class="br0">)</span><span class="sy4">;</span>   <span class="co1">// error: cannot define new types in a sizeof expression</span>
<span class="kw1">using</span> t <span class="sy1">=</span> <span class="kw1">struct</span> <span class="br0">{</span> <span class="kw4">int</span> x<span class="sy4">;</span> <span class="br0">}</span><span class="sy4">;</span> <span class="co1">// creates a new type and declares t as an alias of that type</span>
 
sizeof<span class="br0">(</span><span class="kw4">static</span> <span class="kw4">int</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// error: storage class specifiers not part of type-specifier-seq</span>
<a href="../utility/functional/function.html"><span class="kw1064">std::<span class="me2">function</span></span></a><span class="sy1">&lt;</span><span class="kw1">inline</span> <span class="kw4">void</span><span class="br0">(</span><span class="kw4">int</span><span class="br0">)</span><span class="sy1">&gt;</span> f<span class="sy4">;</span> <span class="co1">// error: neither are function specifiers</span></pre></div></div>
<p>The <span class="t-spar">declarator</span> part of the declaration grammar with the name removed is referred to as <span class="t-spar">abstract-declarator</span>.
</p><p>Type-id may be used in the following situations:
</p>
<ul><li> to specify the target type in <a href="expressions.html#Conversions" title="cpp/language/expressions">cast expressions</a>;
</li><li> as arguments to <a href="sizeof.html" title="cpp/language/sizeof">sizeof</a>, <a href="alignof.html" title="cpp/language/alignof">alignof</a>, <a href="alignas.html" title="cpp/language/alignas">alignas</a>, <a href="new.html" title="cpp/language/new">new</a>, and <a href="typeid.html" title="cpp/language/typeid">typeid</a>;
</li><li> on the right-hand side of a <a href="type_alias.html" title="cpp/language/type alias">type alias</a> declaration;
</li><li> as the trailing return type of a <a href="function.html" title="cpp/language/function">function</a> declaration;
</li><li> as the default argument of a <a href="template_parameters.html#Type_template_parameter" title="cpp/language/template parameters">template type parameter</a>;
</li><li> as the template argument for a <a href="template_parameters.html#Template_type_arguments" title="cpp/language/template parameters">template type parameter</a>;
</li></ul>
 <table class="t-rev-begin">
<tr class="t-rev t-until-cxx17"><td>
<ul><li> in <a href="except_spec.html" title="cpp/language/except spec">dynamic exception specification</a>.
</li></ul>
</td>
<td><span class="t-mark-rev t-until-cxx17">(until C++17)</span></td></tr>
</table>
<p>Type-id can be used with some modifications in the following situations:
</p>
<ul><li> in the parameter list of a <a href="function.html#Parameter_list" title="cpp/language/function">function</a> (when the parameter name is omitted), type-id uses <span class="t-spar">decl-specifier-seq</span> instead of <span class="t-spar">type-specifier-seq</span> (in particular, some storage class specifiers are allowed);
</li><li> in the name of a <a href="cast_operator.html" title="cpp/language/cast operator">user-defined conversion function</a>, the abstract declarator cannot include function or array operators.
</li></ul>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">This section is incomplete<br>Reason: 8.2[dcl.ambig.res] if it can be compactly summarized </td></tr></table>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">This section is incomplete<br>Reason: mention and link to decltype and auto </td></tr></table>
<h3><span class="mw-headline" id="Elaborated_type_specifier">Elaborated type specifier</span></h3>
<p>Elaborated type specifiers may be used to refer to a previously-declared class name (class, struct, or union) or to a previously-declared enum name even if the name was <a href="lookup.html" title="cpp/language/lookup">hidden by a non-type declaration</a>. They may also be used to declare new class names.
</p><p>See <a href="elaborated_type_specifier.html" title="cpp/language/elaborated type specifier">elaborated type specifier</a> for details.
</p>
<h3><span class="mw-headline" id="Static_type">Static type</span></h3>
<p>The type of an expression that results from the compile-time analysis of the program is known as the <i>static type</i> of the expression. The static type does not change while the program is executing.
</p>
<h3><span class="mw-headline" id="Dynamic_type">Dynamic type</span></h3>
<p>If some <a href="value_category.html" title="cpp/language/value category">glvalue expression</a> refers to a <a href="objects.html" title="cpp/language/object">polymorphic object</a>, the type of its most derived object is known as the dynamic type.
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co1">// given</span>
<span class="kw1">struct</span> B <span class="br0">{</span> <span class="kw1">virtual</span> ~B<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span><span class="br0">}</span> <span class="br0">}</span><span class="sy4">;</span> <span class="co1">// polymorphic type</span>
<span class="kw1">struct</span> D<span class="sy4">:</span> B <span class="br0">{</span><span class="br0">}</span><span class="sy4">;</span>               <span class="co1">// polymorphic type</span>
 
D d<span class="sy4">;</span> <span class="co1">// most-derived object</span>
B<span class="sy2">*</span> ptr <span class="sy1">=</span> <span class="sy3">&amp;</span>d<span class="sy4">;</span>
 
<span class="co1">// the static type of (*ptr) is B</span>
<span class="co1">// the dynamic type of (*ptr) is D</span></pre></div></div>
<p>For prvalue expressions, the dynamic type is always the same as the static type.
</p>
<h3><span class="mw-headline" id="Incomplete_type">Incomplete type</span></h3>
<p>The following types are <i>incomplete types</i>:
</p>
<ul><li> the type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span> (possibly <a href="cv.html" title="cpp/language/cv">cv</a>-qualified);
</li><li> <i>incompletely-defined object types</i>:
<ul><li> class type that has been declared (e.g. by <a href="class.html#Forward_declaration" title="cpp/language/class">forward declaration</a>) but not defined;
</li><li> <a href="array.html#Arrays_of_unknown_bound" title="cpp/language/array">array of unknown bound</a>;
</li><li> array of elements of incomplete type;
</li><li> <a href="enum_class.html" title="cpp/language/enum">enumeration type</a> from the point of declaration until its underlying type is determined.
</li></ul>
</li></ul>
<p>All other types are complete.
</p><p><br>
Any of the following contexts requires type <code>T</code> to be complete:
</p>
<ul><li> <a href="function.html" title="cpp/language/function">definition</a> of or call to a function with return type <code>T</code> or argument type <code>T</code>;
</li><li> <a href="definition.html" title="cpp/language/definition">definition</a> of an object of type <code>T</code>;
</li><li> declaration of a <a href="data_members.html" title="cpp/language/data members">non-static class data member</a> of type <code>T</code>;
</li><li> <a href="new.html" title="cpp/language/new">new-expression</a> for an object of type <code>T</code> or an array whose element type is <code>T</code>;
</li><li> <a href="implicit_cast.html#Lvalue_to_rvalue_conversion" title="cpp/language/implicit cast" class="mw-redirect">lvalue-to-rvalue conversion</a> applied to a glvalue of type <code>T</code>;
</li><li> an <a href="implicit_cast.html" title="cpp/language/implicit cast" class="mw-redirect">implicit</a> or <a href="explicit_cast.html" title="cpp/language/explicit cast">explicit</a> conversion to type <code>T</code>;
</li><li> a <a href="implicit_cast.html" title="cpp/language/implicit cast" class="mw-redirect">standard conversion</a>, <a href="dynamic_cast.html" title="cpp/language/dynamic cast">dynamic_cast</a>, or <a href="static_cast.html" title="cpp/language/static cast">static_cast</a> to type <code>T*</code> or <code>T&amp;</code>, except when converting from the <a href="pointer.html#Null_pointers" title="cpp/language/pointer">null pointer constant</a> or from a <a href="pointer.html#Pointers_to_void" title="cpp/language/pointer">pointer to possibly cv-qualified void</a>;
</li><li> <a href="operator_member_access.html" title="cpp/language/operator member access">class member access operator</a> applied to an expression of type <code>T</code>;
</li><li> <a href="typeid.html" title="cpp/language/typeid">typeid</a>, <a href="sizeof.html" title="cpp/language/sizeof">sizeof</a>, or <a href="alignof.html" title="cpp/language/alignof">alignof</a> operator applied to type <code>T</code>;
</li><li> <a href="operator_arithmetic.html" title="cpp/language/operator arithmetic">arithmetic operator</a> applied to a pointer to <code>T</code>;
</li><li> definition of a class with base class <code>T</code>;
</li><li> assignment to an lvalue of type <code>T</code>;
</li><li> a <a href="try_catch.html" title="cpp/language/try catch">catch-clause</a> for an exception of type <code>T</code>, <code>T&amp;</code>, or <code>T*</code>.
</li></ul>
<p>(In general, when the size and layout of <code>T</code> must be known.)
</p><p>If any of these situations occur in a translation unit, the definition of the type must appear in the same translation unit. Otherwise, it is not required.
</p><p><br>
An incompletely-defined object type can be completed:
</p>
<ul><li> A class type (such as <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">class</span> X</span></span>) might be incomplete at one point in a translation unit and complete later on; the type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">class</span> X</span></span> is the same type at both points:
</li></ul>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw1">struct</span> X<span class="sy4">;</span>            <span class="co1">// X is an incomplete type</span>
<span class="kw4">extern</span> X<span class="sy2">*</span> xp<span class="sy4">;</span>        <span class="co1">// xp is a pointer to an incomplete type</span>
 
<span class="kw4">void</span> foo<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    xp<span class="sy2">++</span><span class="sy4">;</span>            <span class="co1">// ill-formed: X is incomplete</span>
<span class="br0">}</span>
 
<span class="kw1">struct</span> X <span class="br0">{</span> <span class="kw4">int</span> i<span class="sy4">;</span> <span class="br0">}</span><span class="sy4">;</span> <span class="co1">// now X is a complete type</span>
X x<span class="sy4">;</span>
 
<span class="kw4">void</span> bar<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    xp <span class="sy1">=</span> <span class="sy3">&amp;</span>x<span class="sy4">;</span>         <span class="co1">// OK: type is “pointer to X”</span>
    xp<span class="sy2">++</span><span class="sy4">;</span>            <span class="co1">// OK: X is complete</span>
<span class="br0">}</span></pre></div></div>
<ul><li> The declared type of an array object might be an array of incomplete class type and therefore incomplete; if the class type is completed later on in the translation unit, the array type becomes complete; the array type at those two points is the same type.
</li></ul>
<ul><li> The declared type of an array object might be an array of unknown bound and therefore be incomplete at one point in a translation unit and complete later on; the array types at those two points ("array of unknown bound of <span class="t-c"><span class="mw-geshi cpp source-cpp">T</span></span>" and "array of <span class="t-c"><span class="mw-geshi cpp source-cpp">N</span></span> <span class="t-c"><span class="mw-geshi cpp source-cpp">T</span></span>") are different types.
</li></ul>
<p>The type of a pointer to array of unknown bound, or to a type defined by a <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">typedef</span></span></span> declaration to be an array of unknown bound, cannot be completed.
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw4">extern</span> <span class="kw4">int</span> arr<span class="br0">[</span><span class="br0">]</span><span class="sy4">;</span>   <span class="co1">// the type of arr is incomplete</span>
<span class="kw1">typedef</span> <span class="kw4">int</span> UNKA<span class="br0">[</span><span class="br0">]</span><span class="sy4">;</span> <span class="co1">// UNKA is an incomplete type</span>
 
UNKA<span class="sy2">*</span> arrp<span class="sy4">;</span>         <span class="co1">// arrp is a pointer to an incomplete type</span>
UNKA<span class="sy2">**</span> arrpp<span class="sy4">;</span>
 
<span class="kw4">void</span> foo<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    arrp<span class="sy2">++</span><span class="sy4">;</span>         <span class="co1">// error: incomplete type</span>
    arrpp<span class="sy2">++</span><span class="sy4">;</span>        <span class="co1">// OK: sizeof UNKA* is known</span>
<span class="br0">}</span>
 
<span class="kw4">int</span> arr<span class="br0">[</span><span class="nu0">10</span><span class="br0">]</span><span class="sy4">;</span>        <span class="co1">// now the type of arr is complete</span>
 
<span class="kw4">void</span> bar<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    arrp <span class="sy1">=</span> <span class="sy3">&amp;</span>arr<span class="sy4">;</span>    <span class="co1">// error: different types</span>
    arrp<span class="sy2">++</span><span class="sy4">;</span>         <span class="co1">// error: UNKA can’t be completed</span>
<span class="br0">}</span></pre></div></div>
<h3><span class="mw-headline" id="Defect_Reports">Defect Reports</span></h3>
<p>The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
</p>
<table class="dsctable" style="font-size:0.8em">
<tr>
<th> DR
</th>
<th> Applied to
</th>
<th> Behavior as published
</th>
<th> Correct behavior
</th></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/328.html">CWG 328</a>
</td>
<td> C++98
</td>
<td> class members of incomplete type were not prohibited<br> if an object of the class type was never created
</td>
<td> non-static class data members<br>need to be complete
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/977.html">CWG 977</a>
</td>
<td> C++98
</td>
<td> the point when an enumeration type becomes<br>complete in its definition was unclear
</td>
<td> the type is complete once the<br>underlying type is determined
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1362.html">CWG 1362</a>
</td>
<td> C++98
</td>
<td> user-defined conversions to type <code>T*</code> or <code>T&amp;</code> required <code>T</code> to be complete
</td>
<td> not required
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/2006.html">CWG 2006</a>
</td>
<td> C++98
</td>
<td> cv-qualified <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span> types were object type and complete type
</td>
<td> excluded from both categories
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/2448.html">CWG 2448</a>
</td>
<td> C++98
</td>
<td> only cv-unqualified types could be integral and floating-point types
</td>
<td> allowed cv-qualified types
</td></tr></table>
<h3><span class="mw-headline" id="See_also">See also</span></h3>
<table class="t-dsc-begin">

</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 5810/1000000
Preprocessor generated node count: 12954/1000000
Post‐expand include size: 145047/2097152 bytes
Template argument size: 21566/2097152 bytes
Highest expansion depth: 17/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:13105-0!*!0!!en!*!* and timestamp 20220729020749 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/language/type&amp;oldid=141533">https://en.cppreference.com/mwiki/index.php?title=cpp/language/type&amp;oldid=141533</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>Navigation</h5>
            <ul><li><a href="https://en.cppreference.com/w/cpp/language/type">Online version</a></li><li>Offline version retrieved 2022-07-30 14:05.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> This page was last modified on 28 July 2022, at 19:07.</li>
                                    <li id="footer-info-viewcount">This page has been accessed 361,364 times.</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler","ext.gadget.MathJax"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.038 secs. -->
	</body>
<!-- Cached 20220729020943 -->
</html>